home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / misc / helpf.c < prev    next >
C/C++ Source or Header  |  1996-05-12  |  1KB  |  72 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <sys/stat.h>
  4. #include "misc.h"
  5. #include "../paths.h"
  6.  
  7. static char *lang = strdup("eng");
  8. static HELP_FILE *first = NULL;
  9.  
  10. /*
  11.     Record the language to use for help files
  12. */
  13. void help_setlang (const char *_lang)
  14. {
  15.     free (lang);
  16.     lang = strdup(_lang);
  17. }
  18.  
  19. /*
  20.     Record the spec of a config file that is maintain (or used) by linuxconf
  21. */
  22. PUBLIC HELP_FILE::HELP_FILE(
  23.     const char *_subdir,
  24.     const char *_fname)
  25. {
  26.     /* #Specification: help file / path
  27.         All help file of linuxconf are under the same directory
  28.         USR_LIB_CONF. Each subject (netconf, userconf, etc...) has
  29.         its own subdirectory under this directory. In these
  30.         subdirectories, we have file ending with the extension help.
  31.     */
  32.     subdir = _subdir;
  33.     fname = _fname;
  34.     path = NULL;
  35.     next = first;
  36.     first = this;
  37. }
  38.  
  39. /*
  40.     Return the path of the configuration file
  41. */
  42. PUBLIC const char *HELP_FILE::getpath()
  43. {
  44.     if (path == NULL && fname != NULL){
  45.         char buf[200];
  46.         sprintf (buf,"%s/help.%s/%s/%s",HELP_BASEPATH,lang,subdir,fname);
  47.         path = strdup (buf);
  48.     }    
  49.     return path;
  50. }
  51. /*
  52.     Check if all the help file of the application are there.
  53.     This is a runtime check even if it is only requiered for testing
  54.     the software.
  55. */
  56. void helpf_checkall()
  57. {
  58.     HELP_FILE *f = first;
  59.     while (f != NULL){
  60.         const char *path = f->getpath();
  61.         if (path != NULL){
  62.             struct stat st;
  63.             printf ("%s%s\n"
  64.                 ,stat(path,&st)!=-1 ? "\t" : "***\t"
  65.                 ,path);
  66.         }
  67.         f = f->next;
  68.     }
  69. }
  70.  
  71. HELP_FILE help_nil (NULL,NULL);
  72.